<html>
    <head>
        <link rel="stylesheet" href="css/style.css" type="text/css" id="" media="print, projection, screen" />
        <script type="text/javascript" src="script/jquery-latest.js"></script>
        <script type="text/javascript" src="script/jquery.tablesorter.js"></script>
        <script type="text/javascript" src="script/jquery.tablesorter.pager.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                // call the tablesorter plugin
                $("table").tablesorter({
                    // sort on the first column and third column, order asc
                    sortList: [[0,0]],
                    headers: {
                        // assign the secound column (we start counting zero)
                        5: {
                            // disable it by setting the property sorter to false
                            sorter: false
                        }
                    }
                });
            });


        </script>

        <title>TUP Student Management</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>



        <div id="container" style="width: 100%;background-color: white;">

            <div style="background-color: #8e0202; height: 110px; width: auto; ">
            </div>
            <div align="center" style=" height: 4px; width: auto;"></div>

            <div align="center" style="background-image: url(image/wall11.jpg);  height: 74px; width: auto;">


                <div align="center" style=" height: 4px; width: auto;"></div>
                <div align="center" style=" height: 22px; width: auto;">


                    <a href="TMMViewProf.php"><b>Professor Management</b></a>&nbsp;&nbsp;
                    <a href="SMMViewStud.php"><b>Student Management</b></a>&nbsp;&nbsp;
                    <a href="CMMViewCourse.php"><b>[ Course Management ]</b></a>&nbsp;&nbsp;
                    <a href="EMSelectProf.php"><b>Enrollment</b></a>


                </div>
                <div align="center" style=" height: 4px; width: auto;"></div>
                <div align="center" style=" height: 22px; width: auto;">

                    <a href="SMMAddStud.php" >Add Student&nbsp;</a>

                    <a href="SMMViewStud.php">[ View Student ]&nbsp;</a>

                    <a href="SMMSearchStud.php">Search Student&nbsp;</a>


                </div>

                <div  align="left" style=" height: 18px; width: 50%;float:left;"><?php echo "<aa class=\"smallw\"><b>Welcome " . $_SESSION['fname'] . ", Last login: " . $_SESSION['lastlogin'] . "</b></aa>"; ?>
                </div>
                <div align="right" style=" height: 18px; width: 50%;float:left;"><bb>|</bb>
                    <a class="small" href=""><b>Edit Profile</b></a>
                    <bb>|</bb>
                    <a class="small" href="Logout.php"><b>Logout</b></a>
                    <bb>|</bb></div>


            </div>

            <div align="center" style=" height: 4px; width: auto;"></div>
            <div align="center" style=" float:left; width: 100%; background-image: url(image/wall6.jpg);">


                <h2>View Student</h2>


                <?php
                if (isset($_POST['Cancel'])) {
                    $studidno = $_POST['stude'];
                    echo "<h3>" . $studidno . "</h3>";
                    include 'DBLibrary/config.php';
                    include 'DBLibrary/openDB.php';
                    mysql_select_db($dbname);

                    $query5 = "DELETE FROM student WHERE studidno='" . $studidno . "'";

                    $queryvalue = mysql_query($query5);
                    if ($queryvalue == 0) {
                        echo "<a class=\"red\">" . mysql_errno($conn) . ": " . mysql_error($conn) . "</a>\n";
                        echo "<h3 class=\"err\">Delete Student Failed</h3>";
                    } else if ($queryvalue == 1)
                        echo "<h3 class=\"err\">Student has been deleted</h3>";
                    include 'DBLibrary/closeDB.php';
                }
                ?>

                <?php
                include 'DBLibrary/config.php';
                include 'DBLibrary/openDB.php';

                mysql_select_db($dbname);
                $querystud = "select * from student";
                $allstud = mysql_query($querystud);
                $ctr = 0;
                $numrows = mysql_num_rows($allstud);

                echo "<aa>" . $numrows . " total results</aa>";
                ?>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<table border="4" id="myTable" class="tablesorter" style="width: 95%;" align="center">
                    <thead><tr>
                            <th>Stud ID</th>
                            <th>Last Name</th>
                            <th>Name</th>
                            <th>Gender</th>
                            <th>Tel No</th>
                            <th>Email Address</th>
                            <th>Edit/View All</th>
                            <th>Delete</th>
                        </tr></thead><tbody>

                        <?php
                        while ($row = mysql_fetch_array($allstud)) {
                            $ctr++;
                            //if()
                            //echo "<tr>" . "<td>" . $ctr . "</td>";<th>No.</th>
                            echo "<tr><td>" . $row['studidno'] . "</td>";
                            echo "<td>" . $row['lname'] . "</td>";
                            echo "<td>" . $row['fname'] . "&nbsp;" . $row['mname'] . ".</td>";
                            echo "<td>" . $row['gender'] . "</td>";
                            echo "<td>" . $row['telno'] . "</td>";
                            echo "<td>" . $row['email'] . "</td>";

                            echo "<form name=\"add\" method=\"post\" action=\"SMMEditStud.php\">";
                            echo "<td><input type=\"submit\" name=\"Edit\" value=\"Edit\"/><input type=\"text\" name=\"stude\" size=\"1\" value=\"" . $row['studidno'] . "\" style=\"visibility:hidden;\"/></td>\n";
                            echo "</form>";

                            echo "<form name=\"add\" method=\"post\" action=\"\">";
                            echo "<td><input type=\"submit\" name=\"Cancel\" value=\"Delete\"/><input type=\"text\" name=\"stude\" size=\"1\" value=\"" . $row['studidno'] . "\" style=\"visibility:hidden;\"/></td></tr>\n";
                            echo "</form>";
                        }
                        include 'DBLibrary/closeDB.php';
                        ?> </tbody>
                </table>

            </div>


            <div id="footer" style="background-image: url(image/wall11.jpg);clear:both;text-align:center; height: 26px; width:auto;">
                <div align="center" style=" height: 4px; width: auto;"></div>
                <bb class ="small">Copyright &#169; 2011</bb>
            </div>


        </div>

    </body>
</html>
